/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * ventanaReserva.java
 *
 * Created on 25/06/2010, 12:21:43 PM
 */

package CapaGrafica;
import com.itextpdf.text.BadElementException;
import com.itextpdf.text.DocumentException;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.net.MalformedURLException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.*;
import CapaLogica.ComunicaReserva;
import java.util.Calendar;
import java.util.GregorianCalendar;
import datechooser.beans.DateChooserCombo;
import java.awt.Image;
import java.awt.Toolkit;

/**
 *
 * @author Maria
 */
public class ventanaReserva extends javax.swing.JFrame {

    /** Creates new form ventanaReserva */
    public ventanaReserva() {
        initComponents();
        this.setSize(500,500);
    }


    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jBsolicitar = new javax.swing.JButton();
        jBCancel = new javax.swing.JButton();
        jLCedula = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jCTipoHab = new javax.swing.JComboBox();
        jLDatos = new javax.swing.JLabel();
        inicio = new datechooser.beans.DateChooserCombo();
        fin = new datechooser.beans.DateChooserCombo();
        jLabel1 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        jSeparator1 = new javax.swing.JSeparator();
        jLabel6 = new javax.swing.JLabel();
        jLabel7 = new javax.swing.JLabel();
        jPanel1 = new javax.swing.JPanel();
        jLabel8 = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("Su Reserva:");
        setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        setLocationByPlatform(true);

        jBsolicitar.setText("Realizar");
        jBsolicitar.setName("jBsolicitar"); // NOI18N
        jBsolicitar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jBsolicitarActionPerformed(evt);
            }
        });

        jBCancel.setText("Cancelar");
        jBCancel.setName("jBCancel"); // NOI18N
        jBCancel.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jBCancelActionPerformed(evt);
            }
        });

        jLCedula.setName("jLCedula"); // NOI18N

        jLabel2.setText("Fecha inicio:");
        jLabel2.setName("jLabel2"); // NOI18N

        jLabel3.setText("Fecha Fin:");
        jLabel3.setName("jLabel3"); // NOI18N

        jLabel4.setText("Tipo Habitacion:");
        jLabel4.setName("jLabel4"); // NOI18N

        jCTipoHab.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "<Seleccionar>", "Cabana", "Normal" }));
        jCTipoHab.setName("jCTipoHab"); // NOI18N

        jLDatos.setName("jLDatos"); // NOI18N

        inicio.setFormat(2);
        inicio.setMinDate(menor);

        fin.setFormat(2);
        fin.setMinDate(menor);

        jLabel1.setText("Nombre:");
        jLabel1.setName("jLabel1"); // NOI18N

        jLabel5.setText("Cedula:");
        jLabel5.setName("jLabel5"); // NOI18N

        jSeparator1.setName("jSeparator1"); // NOI18N

        jLabel6.setFont(new java.awt.Font("Trebuchet MS", 0, 36));
        jLabel6.setForeground(new java.awt.Color(0, 51, 204));
        jLabel6.setText("i-Resort.");
        jLabel6.setName("jLabel6"); // NOI18N

        jLabel7.setText("Realice su reserva:");
        jLabel7.setName("jLabel7"); // NOI18N

        jPanel1.setName("jPanel1"); // NOI18N

        jLabel8.setIcon(new javax.swing.ImageIcon(getClass().getResource("/CapaGrafica/reservas.gif"))); // NOI18N
        jLabel8.setName("jLabel8"); // NOI18N

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jLabel8)
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addComponent(jLabel8, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(jLabel6, javax.swing.GroupLayout.PREFERRED_SIZE, 389, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
            .addComponent(jSeparator1, javax.swing.GroupLayout.DEFAULT_SIZE, 502, Short.MAX_VALUE)
            .addGroup(layout.createSequentialGroup()
                .addGap(60, 60, 60)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jLabel4)
                        .addContainerGap())
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(jLabel2)
                                .addGap(97, 97, 97)
                                .addComponent(inicio, javax.swing.GroupLayout.DEFAULT_SIZE, 239, Short.MAX_VALUE))
                            .addComponent(jLabel1)
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                                .addGap(50, 50, 50)
                                .addComponent(jBsolicitar)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 133, Short.MAX_VALUE)
                                .addComponent(jBCancel)
                                .addGap(66, 66, 66))
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(jLabel3)
                                .addGap(106, 106, 106)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jCTipoHab, javax.swing.GroupLayout.PREFERRED_SIZE, 112, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(fin, javax.swing.GroupLayout.DEFAULT_SIZE, 239, Short.MAX_VALUE)))
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(jLabel5)
                                .addGap(119, 119, 119)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jLDatos, javax.swing.GroupLayout.DEFAULT_SIZE, 239, Short.MAX_VALUE)
                                    .addComponent(jLCedula, javax.swing.GroupLayout.DEFAULT_SIZE, 239, Short.MAX_VALUE))))
                        .addGap(47, 47, 47))))
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap(192, Short.MAX_VALUE)
                .addComponent(jLabel7, javax.swing.GroupLayout.PREFERRED_SIZE, 124, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(45, 45, 45)
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(99, 99, 99))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(jLabel6, javax.swing.GroupLayout.PREFERRED_SIZE, 32, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(36, 36, 36)
                        .addComponent(jLabel7))
                    .addGroup(layout.createSequentialGroup()
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jPanel1, 0, 44, Short.MAX_VALUE)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jLabel1)
                    .addComponent(jLDatos, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jLabel5)
                    .addComponent(jLCedula, javax.swing.GroupLayout.PREFERRED_SIZE, 21, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel2)
                    .addComponent(inicio, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel3)
                    .addComponent(fin, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(20, 20, 20)
                        .addComponent(jLabel4)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 99, Short.MAX_VALUE)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jBCancel)
                            .addComponent(jBsolicitar))
                        .addGap(48, 48, 48))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(18, 18, 18)
                        .addComponent(jCTipoHab, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addContainerGap())))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents
Calendar menor = new GregorianCalendar();
    private void jBsolicitarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBsolicitarActionPerformed
      ComunicaReserva comunicameAReserva = new ComunicaReserva();

        int indicador = 0;
        try {
            indicador = comunicameAReserva.RegistrarReserva(inicio, fin, jLCedula, jCTipoHab);
        } catch (FileNotFoundException ex) {
            Logger.getLogger(ventanaReserva.class.getName()).log(Level.SEVERE, null, ex);
        } catch (BadElementException ex) {
            Logger.getLogger(ventanaReserva.class.getName()).log(Level.SEVERE, null, ex);
        } catch (MalformedURLException ex) {
            Logger.getLogger(ventanaReserva.class.getName()).log(Level.SEVERE, null, ex);
        } catch (IOException ex) {
            Logger.getLogger(ventanaReserva.class.getName()).log(Level.SEVERE, null, ex);
        } catch (DocumentException ex) {
            Logger.getLogger(ventanaReserva.class.getName()).log(Level.SEVERE, null, ex);
        }

 if(indicador == 0)
     JOptionPane.showMessageDialog(rootPane,"Los Datos De La Reserva Están Incompletos. Intente De Nuevo");
 else
   if (indicador == 1)
     {
     String options[] = {"Sí, Agregar", "No, Gracias"};//Respuestas

      int k = JOptionPane.showOptionDialog(null,"¿Desea Agregar Un Invitado Para Su Reserva ","",JOptionPane.YES_NO_OPTION,JOptionPane.QUESTION_MESSAGE,null,options,options[1]); // Numero de respuestas
      if (k==0)
         {
           ventanaInvitado elInvitado = new ventanaInvitado();
           elInvitado.setVisible(true);
         }
      else if (k==1)
         {
         ventanaPago elPago = new ventanaPago();
         double monto = comunicameAReserva.recibirMonto();
         elPago.setMonto(monto);
         elPago.setVisible(true);
      }
  this.dispose();
     }// TODO add your handling code here:
    }//GEN-LAST:event_jBsolicitarActionPerformed

    private void jBCancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBCancelActionPerformed
       this.setVisible(false); // TODO add your handling code here:
    }//GEN-LAST:event_jBCancelActionPerformed

    /**
    * @param args the command line arguments
    */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new ventanaReserva().setVisible(true);
            }
        });
    }

    public void setjLDatos(String nombreApellido){
        jLDatos.setText(nombreApellido);
    }

   public void setjLCedula(String cedula){
        jLCedula.setText(cedula);
    }


    // Variables declaration - do not modify//GEN-BEGIN:variables
    private datechooser.beans.DateChooserCombo fin;
    private datechooser.beans.DateChooserCombo inicio;
    private javax.swing.JButton jBCancel;
    private javax.swing.JButton jBsolicitar;
    private javax.swing.JComboBox jCTipoHab;
    private javax.swing.JLabel jLCedula;
    private javax.swing.JLabel jLDatos;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JSeparator jSeparator1;
    // End of variables declaration//GEN-END:variables

}
